/**
 * The Quad class models a hand of quad
 * @author Xu Chen
 */
public class Quad extends Hand{
	/**
	 * a constructor for building a hand with the specified player and list of cards.
	 * @param player is the player playing this hand
	 * @param cards is the cards in this hand
	*/
	public Quad(CardGamePlayer player, CardList cards) {
		super(player, cards);
	}
	/**
	*
	*a method for retrieving the top card of this hand.
	*@return the top card of this hand
	*/
	public Card getTopCard() {
		this.sort();
		if (this.getCard(0).getRank()==this.getCard(1).getRank()) {
			return this.getCard(3);
		}else {
			return this.getCard(4);
		}
	}
	/**
	*
	*a method for checking if this is a valid hand.
	*@return true if this hand is valid
	*/
	public boolean isValid() {
		this.sort();
		if(this.size()==5&&(
			(this.getCard(0).getRank()==this.getCard(1).getRank()
			&&this.getCard(0).getRank()==this.getCard(2).getRank()
			&&this.getCard(0).getRank()==this.getCard(3).getRank())
			||
			(this.getCard(1).getRank()==this.getCard(2).getRank()
			&&this.getCard(1).getRank()==this.getCard(3).getRank()
			&&this.getCard(1).getRank()==this.getCard(4).getRank())
			)) {
			return true;
		}else {
			return false;
		}

	};
	/**
	*
	* a method for returning a string specifying the type of this hand
	*@return "Quad"
	*/
	public String getType() {
		return "Quad";
	};
}